<?PHP
function center_block_local_show(){

	global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsModuleConfig;

		//GET MOD CONFIG STUFF
		if (!isset($GLOBALS['xoopsModuleConfig']) || $GLOBALS['xoopsModule']->getVar('dirname') != "local_news") {
		  $modhandler = &xoops_gethandler('module');
		  $module = &$modhandler->getByDirname("local_news");
		  $config_handler = &xoops_gethandler('config');
		  $xoopsModuleConfig = &$config_handler->getConfigsByCat(0,$module->getVar('mid')); 
		  $enableSyndication = $xoopsModuleConfig['enableSyndication'];
		  $inModule = 0;
		}else {
		  $enableSyndication = $xoopsModuleConfig['enableSyndication'];
		  $inModule = 1;
		  return false;//don't return this block if it is in the local_news module itself... will blow up.
		}
		//END GET MOD CONFIG STUFF
		
		
		
		//FUNCTION HANDLE IMAGE URLS
		function getImageUrl($image,$TN=false){
	    //global $xoopsModule;
		if(!ereg('http', $image) && $TN==false){
			return XOOPS_URL."/modules/local_news/media/pictures/".$image;
		}elseif($TN==false){
			return $image;
		}elseif(!ereg('http', $image) && $TN==true){
			return XOOPS_URL."/modules/local_news/media/pictures/".substr_replace($image, '-TN.jpg', -4);
		}else{
			return substr_replace($image, '-TN.jpg', -4);
		}
	  }
		
		
		
		//GET LCOAL NEWS STOIRES
		$result = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("local_news_stories")." WHERE expiration_date > '".mktime()."' AND publish_date < '".mktime(23,59,59,date("m"),date("d"),date("Y"))."' AND soundfile != '' ORDER BY publish_date DESC,ID DESC LIMIT ".$xoopsModuleConfig['NICL']."" ) ;
		if($result){
		    $block = array();	
			while ( $myrow = $xoopsDB->fetchArray($result) ) {
					$block['headline'][] = $myrow['headline'];
					$block['ID'][] = $myrow['ID'];
					$block['storyID'][] = $myrow['storyID'];
					$block['byline'][] = $myrow['byline'];
					$block['dateline'][] = $myrow['dateline'];
					$block['tease'][] = $myrow['tease'];
					$block['copyright'][] = $myrow['copyright'];
					$block['copyrightdate'][] = date("Y",$myrow['publish_date']);
					$block['publish_date'][] = date("Y-m-d",$myrow['publish_date']);
					if($myrow['image']){
						$block['image'][] = getImageUrl($myrow['image']);
						$block['imageTN'][] = getImageUrl($myrow['image'],true);
						$block['imageTNwidth'][] = $myrow['imageTNwidth'];
					}else{
						$block['image'][] = "";
						$block['imageTN'][] = "";
						$block['imageTNwidth'][] = "";
					}
					$block['credit'][] = $myrow['credit'];
					$block['caption'][] = $myrow['caption'];
					$block['body'][] = $myrow['body'];
					
				}//end loop


			
			
				if(isset($block['headline']) && count($block['headline']) > 0){
				//convert $block array back into other type if array
			    $tempBlock=array();
				for($i=0; $i < count($block['storyID']); $i++){
					$tempBlock[] = array("body"=>$block['body'][$i],"caption"=>$block['caption'][$i],"credit"=>$block['credit'][$i],"image"=>$block['image'][$i],"imageTN"=>$block['imageTN'][$i],"imageTNwidth"=>$block['imageTNwidth'][$i],"publish_date"=>$block['publish_date'][$i],"copyrightdate"=>$block['copyrightdate'][$i],"copyright"=>$block['copyright'][$i],"tease"=>$block['tease'][$i],"dateline"=>$block['dateline'][$i],"byline" => $block['byline'][$i],"headline"=>$block['headline'][$i],"ID"=>$block['ID'][$i],"storyID"=>$block['storyID'][$i]);
				}
				$block = $tempBlock;
				//return the bugger
				$all = array("data" => $block,"inModule" => $inModule,"useImages" => $xoopsModuleConfig['centerblock_showImages'],"linkIsImage" => $xoopsModuleConfig['centerblock_LinkIsImage'],"showCopyright" => $xoopsModuleConfig['centerblock_ShowCopyright'],);
				return $all;
				}else{
				 return false;
				}
							
		}else{
		 return false;
		}
		

	
}//end function

?>